util: add hex colors support in styleText#61556
util: add hex colors support in styleText#61556araujogui wants to merge 9 commits intonodejs:mainfrom
styleText#61556Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #61556 +/- ##
=======================================
Coverage 89.71% 89.72%
=======================================
Files 695 695
Lines 214154 214220 +66
Branches 41009 41018 +9
=======================================
+ Hits 192132 192208 +76
+ Misses 14075 14073 -2
+ Partials 7947 7939 -8
🚀 New features to boost your workflow:
|
ljharb
left a comment
There was a problem hiding this comment.
Please add test cases for invalid values.
e4dff45 to
012abfa
Compare
This comment was marked as outdated.
This comment was marked as outdated.
8eb2649 to
e90ab1c
Compare
RafaelGSS
left a comment
There was a problem hiding this comment.
Since we don't have a green CI yet, would you mind including hex to styleText benchmarks? We are working to improve that, and it would be interesting to see if this decreases performance.
f943683 to
c01e52b
Compare
There was a problem hiding this comment.
Pull request overview
Adds support for passing hex color strings (e.g. #ffcc00, #fc0) to util.styleText() by emitting ANSI TrueColor (24-bit) foreground escape sequences, along with tests/docs/bench updates.
Changes:
- Extend
util.styleText()to recognize#RGB/#RRGGBBformats and generate38;2;r;g;bANSI sequences. - Add a new parallel test suite covering valid/invalid hex handling and env/TTY behavior.
- Update util API docs and the existing
styleTextbenchmark to include a hex format case.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
lib/util.js |
Implements hex color parsing and ANSI sequence generation inside styleText(). |
test/parallel/test-util-styletext-hex.js |
Adds comprehensive tests for hex parsing, composition with modifiers, invalid inputs, and env behavior. |
doc/api/util.md |
Documents hex color support for util.styleText(). |
benchmark/util/style-text.js |
Adds a hex format option to benchmark styleText(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
It's http and net tests that are flaky 😅 https://gist.github.com/araujogui/df02946a26166615c857f49cce19e73f Rebased the PR again, maybe this solve the problem |
|
(╯°□°)╯︵ ┻━┻ |
Commit Queue failed- Loading data for nodejs/node/pull/61556 ✔ Done loading data for nodejs/node/pull/61556 ----------------------------------- PR info ------------------------------------ Title util: add hex colors support in `styleText` (#61556) Author Guilherme Araújo <arauujogui@gmail.com> (@araujogui) Branch araujogui:util/colorize-hex -> nodejs:main Labels util, semver-minor, author ready, needs-ci, commit-queue-squash Commits 9 - util: colorize text with hex colors - util: nits - util: non-capturing regex - util: return buffer - doc: add history entry - doc: add final period - doc: profread - util: remove unused import - benchmark: add hex style Committers 1 - Guilherme Araújo <arauujogui@gmail.com> PR-URL: https://github.com/nodejs/node/pull/61556 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Jordan Harband <ljharb@gmail.com> Reviewed-By: René <contact.9a5d6388@renegade334.me.uk> Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Claudio Wunder <cwunder@gnome.org> Reviewed-By: Chemi Atlow <chemi@atlow.co.il> ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/61556 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Jordan Harband <ljharb@gmail.com> Reviewed-By: René <contact.9a5d6388@renegade334.me.uk> Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Claudio Wunder <cwunder@gnome.org> Reviewed-By: Chemi Atlow <chemi@atlow.co.il> -------------------------------------------------------------------------------- ℹ This PR was created on Wed, 28 Jan 2026 01:00:57 GMT ✔ Approvals: 8 ✔ - Michaël Zasso (@targos) (TSC): https://github.com/nodejs/node/pull/61556#pullrequestreview-3723149200 ✔ - Jordan Harband (@ljharb): https://github.com/nodejs/node/pull/61556#pullrequestreview-3724564626 ✔ - René (@Renegade334): https://github.com/nodejs/node/pull/61556#pullrequestreview-3769858571 ✔ - Gürgün Dayıoğlu (@gurgunday): https://github.com/nodejs/node/pull/61556#pullrequestreview-3770404667 ✔ - Antoine du Hamel (@aduh95) (TSC): https://github.com/nodejs/node/pull/61556#pullrequestreview-3822560259 ✔ - Rafael Gonzaga (@RafaelGSS) (TSC): https://github.com/nodejs/node/pull/61556#pullrequestreview-3835624781 ✔ - Claudio Wunder (@ovflowd): https://github.com/nodejs/node/pull/61556#pullrequestreview-4068182347 ✔ - Chemi Atlow (@atlowChemi): https://github.com/nodejs/node/pull/61556#pullrequestreview-4016624350 ✘ 1 GitHub CI job(s) failed: ✘ - Cleanup artifacts: FAILURE (https://github.com/nodejs/node/actions/runs/23858701046/job/69559818402) ℹ Last Full PR CI on 2026-04-07T11:13:20Z: https://ci.nodejs.org/job/node-test-pull-request/72532/ - Querying data for job/node-test-pull-request/72532/ ✔ Build data downloaded ✔ Last Jenkins CI successful -------------------------------------------------------------------------------- ✔ Aborted `git node land` session in /home/runner/work/node/node/.ncuhttps://github.com/nodejs/node/actions/runs/24082735401 |
|
You gotta be kidding me.... @aduh95 do you know how we can bypass https://github.com/nodejs/node/actions/runs/23858701046/job/69559818402? Seems like just a random Copilot error? IDK if retriggering Copilot would ignore that? |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Commit Queue failed- Loading data for nodejs/node/pull/61556 ✔ Done loading data for nodejs/node/pull/61556 ----------------------------------- PR info ------------------------------------ Title util: add hex colors support in `styleText` (#61556) Author Guilherme Araújo <arauujogui@gmail.com> (@araujogui) Branch araujogui:util/colorize-hex -> nodejs:main Labels util, semver-minor, author ready, needs-ci, commit-queue-squash Commits 9 - util: colorize text with hex colors - util: nits - util: non-capturing regex - util: return buffer - doc: add history entry - doc: add final period - doc: profread - util: remove unused import - benchmark: add hex style Committers 1 - Guilherme Araújo <arauujogui@gmail.com> PR-URL: https://github.com/nodejs/node/pull/61556 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Jordan Harband <ljharb@gmail.com> Reviewed-By: René <contact.9a5d6388@renegade334.me.uk> Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Claudio Wunder <cwunder@gnome.org> Reviewed-By: Chemi Atlow <chemi@atlow.co.il> ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/61556 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Jordan Harband <ljharb@gmail.com> Reviewed-By: René <contact.9a5d6388@renegade334.me.uk> Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Claudio Wunder <cwunder@gnome.org> Reviewed-By: Chemi Atlow <chemi@atlow.co.il> -------------------------------------------------------------------------------- ℹ This PR was created on Wed, 28 Jan 2026 01:00:57 GMT ✔ Approvals: 8 ✔ - Michaël Zasso (@targos) (TSC): https://github.com/nodejs/node/pull/61556#pullrequestreview-3723149200 ✔ - Jordan Harband (@ljharb): https://github.com/nodejs/node/pull/61556#pullrequestreview-3724564626 ✔ - René (@Renegade334): https://github.com/nodejs/node/pull/61556#pullrequestreview-3769858571 ✔ - Gürgün Dayıoğlu (@gurgunday): https://github.com/nodejs/node/pull/61556#pullrequestreview-3770404667 ✔ - Antoine du Hamel (@aduh95) (TSC): https://github.com/nodejs/node/pull/61556#pullrequestreview-3822560259 ✔ - Rafael Gonzaga (@RafaelGSS) (TSC): https://github.com/nodejs/node/pull/61556#pullrequestreview-3835624781 ✔ - Claudio Wunder (@ovflowd): https://github.com/nodejs/node/pull/61556#pullrequestreview-4068182347 ✔ - Chemi Atlow (@atlowChemi): https://github.com/nodejs/node/pull/61556#pullrequestreview-4016624350 ✘ 1 GitHub CI job(s) failed: ✘ - Cleanup artifacts: FAILURE (https://github.com/nodejs/node/actions/runs/23858701046/job/69559818402) ℹ Last Full PR CI on 2026-04-07T13:03:37Z: https://ci.nodejs.org/job/node-test-pull-request/72532/ - Querying data for job/node-test-pull-request/72532/ ✔ Build data downloaded ✔ Last Jenkins CI successful -------------------------------------------------------------------------------- ✔ Aborted `git node land` session in /home/runner/work/node/node/.ncuhttps://github.com/nodejs/node/actions/runs/24086140240 |

Fixes #61543